

var formatter = function (value, row, index) {
    return ['<a href="javascript:void(0)" class="deletepark">删除</a>'];
}

window.operateEvents = {
    'click .deletepark': function (e, value, row, index) {
        comment.showOperationTips("确定删除该园区吗？", function () {
            $.post($().AbsUrlParse('/web/park/deletePark'), {
                id: row.id
            }, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("删除成功");
                        var table = $('#table');
                        table.bootstrapTable('refresh');
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }
            });
        });
    }
};



//修改的代码
bindClick("#btnsearch", function () {
    //下面是每次查询
    var parkName = $("input[name=parkName]").val();
    var createdTime = $("input[name=createdTime]").val();
    var startCreatedTime = "";
    var endCreatedTime = "";


    if(createdTime!=""){
        startCreatedTime= createdTime.split(" - ")[0];
        endCreatedTime= createdTime.split(" - ")[1];
    }

    var url = $().AbsUrlParse("/web/park/queryAllParks?parkName="+parkName+"&startCreatedTime="+startCreatedTime+"&endCreatedTime="+endCreatedTime);

    $("#table").bootstrapTable("refresh", {"url": url});
});

//点击添加按钮时的操作
bindClick("#addPark", function () {
    showModel("addPark-div", function () {

    });
});

//提交表单后回调
var savePark = function (data) {
    var d = JSON.parse(data);
    console.log(d);
}

function initDateRange() {
    $(".rangedate").daterangepicker({
        "autoApply": true,
        "locale": {
            "applyLabel": "确定",
            "cancelLabel": "取消",
            "fromLabel": "开始",
            "toLabel": "结束",
            "customRangeLabel": "Custom",
            "weekLabel": "周",
            "daysOfWeek": [
                "日",
                "一",
                "二",
                "三",
                "四",
                "五",
                "六"
            ],
            "monthNames": [
                "1月",
                "2月",
                "3月",
                "4月",
                "5月",
                "6月",
                "7月",
                "8月",
                "9月",
                "10月",
                "11月",
                "12月"
            ],
            "cancelLabel": '清空',
            "opens": "right"
        },
        "format": "YYYY-MM-DD"
    }).on('cancel.daterangepicker', function (ev, picker) {
        $(this).val('');
    });
}

//初始化页面的时候运行该函数
$(function () {
    initDateRange();
});